package top.itmeans.yes.admin.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
import top.itmeans.yes.dto.AdminParam;
import top.itmeans.yes.dto.UpdateAdminPasswordParam;
import top.itmeans.yes.entity.Admin;
import top.itmeans.yes.entity.Role;

import java.util.List;

/**
 * <p>
 * 后台用户表 服务类
 * </p>
 *
 * @author Yiming.Cao
 * @since 2022-04-28
 */
public interface AdminService extends IService<Admin> {

    Admin getAdminByUsername(String username);

    UserDetails loadUserByUsername(String username);

    Admin register(AdminParam umsAdminParam);

    String login(String username, String password);

    String refreshToken(String token);

    List<Role> getRoleList(Long id);

    /**
     * 根据用户名或昵称分页查询用户
     */
    Page<Admin> list(String keyword, Integer pageSize, Integer pageNum);

    int updatePassword(UpdateAdminPasswordParam updatePasswordParam);

    int update(Long id, Admin admin);

    /**
     * 修改用户角色关系
     */
    @Transactional
    int updateRole(Long adminId, List<Long> roleIds);
}

